import 'package:flutter/material.dart';
import 'package:flutter_audit_app/res/colors.dart';
import 'package:flutter_audit_app/res/styles.dart';

class LabelValue extends StatelessWidget {
  final String label;
  final String _value;
  final bool _showColon;

  LabelValue(this.label, {String value, bool showColon = true})
      : _value = value,
        _showColon = showColon;

  ///计算文本长度
  String showTextTabLabel() {
    switch (label.length) {
      case 2:
        return _showColon
            ? '$label:\t\t\t\t\t\t\t\t'
            : '$label\t\t\t\t\t\t\t\t';
      case 3:
        return _showColon ? '$label:\t\t\t\t\t\t' : '$label\t\t\t\t\t\t';
      case 4:
        return _showColon ? '$label:\t' : '$label\t';
      case 5:
        return _showColon ? '$label:' : '$label';
    }
    return '';
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      height: height(50),
      child: Row(
        // mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text(
            showTextTabLabel(),
            style: TextStyle(fontSize: 12, color: Colours.u_666666),
          ),
          Expanded(
            child: Text(
              '\t\t\t$_value',
              style: TextStyles.textSize12AndBlack,
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
            ),
          ),
        ],
      ),
    );
  }

// @override
// State<StatefulWidget> createState() => _LabelValueState();

}

/*class _LabelValueState extends State<LabelValue> {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: height(50),
      child: Row(
        children: <Widget>[
          Text(
            widget.label,
            style: TextStyle(fontSize: 12, color: Colours.u_666666),
          ),
          Expanded(
            child: Text(
              '\t\t\t${widget._value}',
              style: TextStyles.textSize12AndBlack,
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
            ),
          ),
        ],
      ),
    );
  }
}*/
